{% extends 'base.html' %}

{% load staticfiles %}

{% block title %}课程详情{% endblock %}
{% block crumbs%}
<!--crumbs start-->
<section>
	<div class="wp">
		<div class="crumbs">
			<ul>
				<li><a href="{% url 'index' %}">首页</a>></li>
                <li><a href="{% url 'courses:list' %}">公开课</a>></li>
				<li>课程详情</li>
			</ul>
		</div>
	</div>
</section>
{% endblock %}
{% block body %}
<section>
	<div class="wp">
		<div class="groupPurchase_detail detail">
			<div class="toppro">
				<div class="left">
					<div class="picbox">
						<div class="tb-booth tb-pic">
							<img width="440" height="445" src="{{ MEDIA_URL }}{{ course.image }}" class="jqzoom" />
						</div>

					</div>
					<div class="des">
						<h1 title="{{ course.name }}体验开始了">{{ course.name }}</h1>
						<span class="key">{{ course.desc }}</span>
						<div class="prize">
							<span class="fl">难度：<i class="key">{{ course.get_degree_display }}</i></span>
							<span class="fr">学习人数：{{ course.students }}</span>
						</div>
						<ul class="parameter">
							<li><span class="pram word3">时&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;长：</span><span>{{ course.learn_time }}</span></li>
                            <li><span class="pram word3">章&nbsp;节&nbsp;数：</span><span>{{ course.lession_nums }}</span></li>
                            <li><span class="pram word3">课程类别：</span><span title="">{{ course.category }}</span></li>
							<li class="piclist"><span class="pram word4">学习用户：</span>
                                {% for user in users %}
                                    <span class="pic"><img width="40" height="40" src="{{ MEDIA_URL }}{{ user.user.image }}"/></span>
                                {% endfor %}

							</li>

						</ul>
                            <div class="btns">
                                <div class="btn colectgroupbtn"  id="jsLeftBtn">
                                    {% if is_course_fav %}
                                        已收藏
                                        {% else %}
                                        收藏
                                    {% endif %}
                                </div>
                                <div class="buy btn"><a style="color: white" href="{% url 'courses:video' course.id%}">开始学习</a></div>
                            </div>
					</div>
{#                    <div class="group-share-box">#}
{#                        <div class="bdsharebuttonbox"#}
{#                             data-text="精品课程-{{ course.name }}-在线学习网"#}
{#                             data-desc="我在#在线学习网#发现了精品课程“{{ course.name }}”，对学习中的小伙伴很有帮助，一起来看看吧。"#}
{#                             data-comment=""#}
{#                             data-url="{% url 'courses:detail' course.id%}">#}
{#                            <span class="fl">分享到：</span>#}
{#                            <a href="#" class="bds_more" data-cmd="more"></a>#}
{#                            <a title="分享到QQ空间" href="#" class="bds_qzone" data-cmd="qzone"></a>#}
{#                            <a title="分享到新浪微博" href="#" class="bds_tsina" data-cmd="tsina"></a>#}
{#                            <a title="分享到腾讯微博" href="#" class="bds_tqq" data-cmd="tqq"></a>#}
{#                            <a title="分享到人人网" href="#" class="bds_renren" data-cmd="renren"></a>#}
{#                            <a title="分享到微信" href="#" class="bds_weixin" data-cmd="weixin"></a>#}
{#                        </div>#}
{#                    </div>#}
				</div>
				<div class="right">
					<div class="head">
						<h1>{{ course.course_org.name }}</h1>
                    {% ifequal course.course_org.category 'gx' %}
                        <p>知名高校，权威教学</p>
                    {% endifequal %}
                    {% ifequal course.course_org.category 'pxjg' %}
                        <p>知名机构，权威教学</p>
                    {% endifequal %}
                    {% ifequal course.course_org.category 'gr' %}
                        <p>知名学者，权威教学</p>
                    {% endifequal %}
					</div>
					<div class="pic">
                        <a href="{% url 'org:org_home' course.course_org.id %}">
                            <img width="150" height="80" src="{{ MEDIA_URL }}{{ course.course_org.image }}"/>
                        </a>
                    </div>
					<a href="{% url 'org:org_home' course.course_org.id %}">
                        <h2 class="center" title="{{ course.course_org.name }}">{{ course.course_org.name }}</h2>
                    </a><br>
                    <p class="center tell">地址：{{ course.course_org.address }}</p>
                    <div class="center">
                        <a class="btn  notlogin" data-favid="14" id="jsRightBtn">
                            {% if is_fav %}
                                已收藏
                            {% else %}
                                收藏
                            {% endif %}

                        </a>
                    </div>
                    <br>
                    <ul class="color-gray">
                      <li><span>&ensp;课 &nbsp;程&nbsp; 数：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   {{ course.course_org.course_nums }}</span></li><br>
                      <li><span>&ensp;教 &nbsp;师&nbsp; 数：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  {{ course.course_org.get_teacher_nums }}</span></li>
                    </ul>

				</div>
			</div>
		</div>
	</div>
</section>
{#课程详情#}
<section>
	<div class="wp">
		<div class="list groupPurchase_detail_pro">
			<div class="left layout">
				<div class="head">
					<ul class="tab_header"><li class="active">课程详情</li></ul>
				</div>
				<div class="tab_cont tab_cont1">
                    
					<p>{{ course.detail }}</p>
		        </div>
            </div>
        </div>
	</div>
</section>
{% endblock %}

{% block custom_js %}
<script type="text/javascript">
//收藏分享
function add_fav(current_elem, fav_id, fav_type){
    $.ajax({
        cache: false,
        type: "POST",
        url:"{% url 'org:add_fav' %}",
        data:{'fav_id':fav_id, 'fav_type':fav_type},
        async: true,
        beforeSend:function(xhr, settings){
            xhr.setRequestHeader("X-CSRFToken", "{{ csrf_token }}");
        },
        success: function(data) {
            if(data.status == 'fail'){
                if(data.msg == '用户未登录'){
                    window.location.href="{% url 'users:login' %}";
                }else{
                    alert(data.msg)
                }

            }else if(data.status == 'success'){
                current_elem.text(data.msg)
            }
        },
    });
}

$('#jsLeftBtn').on('click', function(){
    add_fav($(this), {{ course.id }}, 0);
});

$('#jsRightBtn').on('click', function(){
    add_fav($(this), {{ course.course_org.id }}, 1);
});


</script>
{% endblock %}


